//获取应用实例
var app = getApp();
Page({
    data: {
        orderList:[],
        location:"doing"
    },
    onLoad: function (option) {
        this.queryOrderList(this,app.globalData.openId,option.bizFlag);
    },
    queryOrderList:function (pageObj,accountId,bizFlag) {
        var opt = {
            url: app.globalData.host+"/wx/cn/list.ajax",
            data: {
                'accountId':accountId,
                'bizFlag':bizFlag,
                'orderType':app.globalData.orderType
            },
            sucFn:function (result) {
                var location = "doing";
                if(bizFlag==app.globalData.bizDoingFlag){
                    location = "doing";
                }else if(bizFlag==app.globalData.bizFinishFlag){
                    location = "finish";
                }else if(bizFlag==app.globalData.bizAllFlag){
                    location = "all";
                }
                pageObj.setData({
                    orderList:result.body.orderList,
                    location: location
                })
            }
        };
        app.ajax(opt);
    },
    doingTap:function (e) {
        this.queryOrderList(this,app.globalData.openId,app.globalData.bizDoingFlag);
    },
    finishTap:function (e) {
        this.queryOrderList(this,app.globalData.openId,app.globalData.bizFinishFlag);
    },
    allTap:function (e) {
        this.queryOrderList(this,app.globalData.openId,app.globalData.bizAllFlag);
    },
    orderDetailTap:function (e) {
        var orderId = e.currentTarget.id;
        app.navigateTo({
            url: '../orderdetail/orderdetail?orderId='+orderId
        });
    }
});
